Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Passing sbit address as function parameters on 8051

Status
Not open for further replies.

x_zoli

Advanced Member level 4
Full Member level 1
Joined
Jul 22, 2004
Messages
105
Helped
9
Reputation
18
Reaction score
3
Trophy points
1,298
Location
Brasov, Romania
Visit site
Activity points
787
8051 parameters

Hi all

Can anyone tell me how to pass sbit and/or sfr addresses as function parameters in Ke*il, so that later on I can assign values to those sbits or sfrs (more specifically port pins, or an entire port).
I am trying to write a set of LCD functions (HD44780 compatible) and make it a library. Using it as a library, I have to make it flexible to the level that the data port and control pins can be specified by the means of library functions. This is where my problem begins.

Thanks
 

sbit-address 8051

SFR addresses and bits are not possible as params in Keil
See also the c51 manual

usbman
 

sbit 8051

Hello

Here is how to access an SFR using it's address C language

//Set Ptr to the address - if the SFR lay at address 99H :

#define sfr_test 0x099 //0x099 is the SFR address

void ChangeSfr(unsigned char *SfrData)
{
//Set the value of the SFR to 55H
SfrData = 0x55;

}


//Function call
ChangeSfr((unsigned char *)sfr_test);


I don't think you can use this methode to access a single bit !
regards

Bobi
 

sbit in keil

to pass bits as function parameters define the bit as an sbit at the beginning of the program and then use the same definition as the function parameter
e.g:-
sbit ACC_0=0xE0;
void a_func(ACC_0)
{
}
This works as long as the function calling is properly defined
This has been tried and tested in Keil(uvision 2)
ayan
 

passing sfr values in function in 8051

none of the above soulutions will work
params are passed in registers! in Keil

please check the asm output

usbman
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top